package com.corecode.common.zip.catalog.impl;

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import com.corecode.common.zip.catalog.CatalogMapGenerator;

public class DefaultCatalogGenerator implements CatalogMapGenerator {
	
	private static final String ROOT_WELCOME_CATALOG = "\\ROOT\\images\\";
	
	private static final String ROOT_WELCOME_PTCTURE = "welcome_font.jpg";
	private static final String ROOT_WELCOME_PTCTURE_EN = "welcome_font_en.jpg";
	private static final String ROOT_WELCOME_PTCTURE_TAI = "welcome_font_tai.jpg";
	
	private static final String COMING_CATALOG = "\\images\\";
	
	private static final String COMING_FONT_PTCTURE = "top_font.jpg";
	
	private static final String COMING_LOGO_PTCTURE = "top_logo.jpg";
	
	private Map<String, String> catalogs= new HashMap<String, String>();
	
	private Set<String> keys = new HashSet<String>();
	
	public DefaultCatalogGenerator(Collection keys) {
		this.keys = (Set<String>) keys;
	}
	
	@Override
	public Map generator(String parentDir){
		if (keys != null) {
			String key = "";
			String catalog = "";
			for (Iterator it = keys.iterator(); it.hasNext();) {
				key = (String) it.next();
				if (ROOT_WELCOME_PTCTURE.equalsIgnoreCase(key)) {
					//edit by songyan 2010-03-23
					String rootImagesPath =parentDir.substring(0, parentDir.substring(0, parentDir.length()-1).lastIndexOf("\\"))
					+ ROOT_WELCOME_CATALOG;
					catalogs.put(key, rootImagesPath + key);
					//edit by songyan 2010-03-23
				} else if(ROOT_WELCOME_PTCTURE_EN.equalsIgnoreCase(key)){
					//edit by songyan 2010-03-23
					String rootImagesPath =parentDir.substring(0, parentDir.substring(0, parentDir.length()-1).lastIndexOf("\\"))
					+ ROOT_WELCOME_CATALOG;
					catalogs.put(key, rootImagesPath + key);
					//edit by songyan 2010-03-23
					
				}else if(ROOT_WELCOME_PTCTURE_TAI.equalsIgnoreCase(key)){
					//edit by songyan 2010-03-23
					String rootImagesPath =parentDir.substring(0, parentDir.substring(0, parentDir.length()-1).lastIndexOf("\\"))
					+ ROOT_WELCOME_CATALOG;
					catalogs.put(key, rootImagesPath + key);
					//edit by songyan 2010-03-23
					
				}else if (COMING_FONT_PTCTURE.equalsIgnoreCase(key)) {
					catalogs.put(key, parentDir + COMING_CATALOG + key);
				} else if (COMING_LOGO_PTCTURE.equalsIgnoreCase(key)) {
					catalogs.put(key, parentDir + COMING_CATALOG + key);
				} else {
					// catalogs.put(key, FileSearchUtil.searchDestFileDirectoryToString(parentDir, key));
				}
			}
		}
		return catalogs;
	}
}
